package lagou.homework.lagouhomework.Unit3.code.q1;

public class CharCount {
    public static void main(String[] args) {
        int cntUpper= 0 ;  // 记录大写字母数量
        int cntLower= 0 ;  // 记录小写字母数量
        int cntNum = 0;    // 记录数字数量
        int cntOther =0 ;    // 记录其他字符数量
        String upper ="";
        String lower = "";
        String num = "";
        String other = "";

        String s1 = "ABCD123!@#$%ab";

        char[] arr1 = s1.toCharArray();
        for(int i=0;i<arr1.length;i++){
            // System.out.println(arr1[i]);
            if(Character.isUpperCase(arr1[i])){
                cntUpper = cntUpper + 1;
                upper  = upper + arr1[i];
            }else if(Character.isLowerCase(arr1[i])){
                cntLower = cntLower + 1;
                lower  = lower + arr1[i];
            }else if(Character.isDigit(arr1[i])){
                cntNum = cntNum +1;
                num = num + arr1[i];
            }else{
                cntOther = cntOther +1 ;
                other = other + arr1[i];
            }

        }

        System.out.println("大写字母有" + cntUpper +"个，内容为：" + upper );
        System.out.println("小写字母有" + cntLower +"个，内容为：" + lower );
        System.out.println("数字有" + cntNum +"个，内容为：" + num );
        System.out.println("其他字符有" + cntOther +"个，内容为：" + other );

    }
}
